package com.neuedu.service.impl;

import com.alibaba.cloud.commons.lang.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.neuedu.entity.DrugInfo;
import com.neuedu.mapper.DrugInfoMapper;
import com.neuedu.service.DrugInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author LiYang
 * @since 2024-11-19
 */
@Service
public class DrugInfoServiceImpl extends ServiceImpl<DrugInfoMapper, DrugInfo> implements DrugInfoService {
    @Override
    public List<DrugInfo> list(String drugName, String mnemonicCode) {
        QueryWrapper<DrugInfo> wrapper = new QueryWrapper<>();
        if (StringUtils.isNotBlank(drugName)) { // 判断字符串是否为空
            wrapper.like("drug_name", drugName);
        }
        if (StringUtils.isNotBlank(mnemonicCode)) {
            wrapper.likeRight("mnemonic_code", mnemonicCode);
        }
        return this.list(wrapper);
    }
}
